//
//  ViewController.m
//  王宇先_25_代码约束自定义cell
//
//  Created by 王宇先 on 16/4/13.
//  Copyright © 2016年 王宇先. All rights reserved.
//

#import "ViewController.h"
#import "TableViewOfFilm.h"
#import "CellOfFilm.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, retain)TableViewOfFilm *tableView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self createTableView];
    
}
#pragma mark - 创建 TableView
- (void)createTableView{
    self.tableView = [[TableViewOfFilm alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    //指定代理人
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorColor = [UIColor redColor];
    
    //注册xib 格式的 Cell
    UINib *nib = [UINib nibWithNibName:@"CellOfFilm" bundle:[NSBundle mainBundle]];
    [self.tableView registerNib:nib forCellReuseIdentifier:@"pool"];
}
#pragma mark - delegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CellOfFilm *cell = [tableView dequeueReusableCellWithIdentifier:@"pool"];
    cell.selectionStyle = UITableViewCellAccessoryNone;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 250;
}



#pragma mark - other
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
